import { Agent } from './agent.js';
import { LLMConfig } from './llm.js';
import { MCPConfig } from './mcp/mcp.js';
import { agentEnv } from './config.js';

async function main() {
    const mcpConfig: MCPConfig = {
        configFilePath: agentEnv.mcpConfig.mcpFilePath,
    }
    const llmConfig: LLMConfig = {
        baseUrl: agentEnv.llmConfig.baseUrl,
        apiKey: agentEnv.llmConfig.apiKey,
        model: agentEnv.llmConfig.model,
    }
    const agent: Promise<Agent> = Agent.create(mcpConfig, llmConfig);

    try {
        await (await agent).chatLoop();
    } catch (error) {
        console.log(error);
    } finally {
        await (await agent).cleanup();
        process.exit(0);
    }
}

main();